package code._14thread.api;

public class Demo {
    public static void main(String[] args) {
        Thread thread = Thread.currentThread();
        System.out.println("thread.getName()= "+thread.getName());
        MyThread t = new MyThread("B");
        t.start();

    }
}

class MyThread extends Thread{
    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            // getName() 获取线程名称
            // Thread-0
            // System.out.println(getName() + "---" + i);
            System.out.println(Thread.currentThread().getName() + "---" + i);
        }
    }
}
